package com.kadron.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.kadron.base.KTBase;
import com.kadron.enumeration.DiscountType;

@Entity
@Table(name = "k_discount")
public class Discount extends KTBase implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5576399001134635490L;

	private boolean active;
	private Date validFrom;
	private Date validTo;

	private int kadrons;
	private int bonusKadrons;
	private int percent;
	
	private DiscountType type;

	public Discount() {
		super();
	}
	
	@Column(name = "active", nullable = false)
	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "valid_from")
	public Date getValidFrom() {
		return validFrom;
	}

	public void setValidFrom(Date validFrom) {
		this.validFrom = validFrom;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "valid_to")
	public Date getValidTo() {
		return validTo;
	}

	public void setValidTo(Date validTo) {
		this.validTo = validTo;
	}

	@Column(name = "kadrons")
	public int getKadrons() {
		return kadrons;
	}

	public void setKadrons(int kadrons) {
		this.kadrons = kadrons;
	}

	@Column(name = "bonus_kadrons")
	public int getBonusKadrons() {
		return bonusKadrons;
	}

	public void setBonusKadrons(int bonusKadrons) {
		this.bonusKadrons = bonusKadrons;
	}

	@Column(name = "percent")
	public int getPercent() {
		return percent;
	}

	public void setPercent(int percent) {
		this.percent = percent;
	}
	
	@Column(name = "type", nullable = false, updatable = false)
	public DiscountType getType() {
		return type;
	}

	public void setType(DiscountType type) {
		this.type = type;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Discount other = (Discount) obj;
		if (id != other.id)
			return false;
		return true;
	}

}
